package com.feng.vhr.controller;

import com.feng.vhr.common.RespBean;
import com.feng.vhr.response.RHr;
import com.feng.vhr.response.Rmenu;
import com.feng.vhr.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/system/config")
public class SysController {
    @Autowired
    private IMenuService menuService;

    /**
     * 获取菜单列表
     * @param session
     * @return
     */
    @GetMapping("/menu")
    public RespBean menu(HttpSession session){
//        Hr user = (Hr) session.getAttribute("user");
        List<Rmenu> menuByRole = menuService.getMenuByRole(((RHr) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
        return RespBean.ok("",menuByRole);
    }
}
